package com.juzipi.demo.utils;

import com.baomidou.mybatisplus.core.toolkit.AES;

public class Encrypt {
    public static void main(String[] args) {
        // 生成 16 位随机 AES 密钥
        String randomKey = AES.generateRandomKey();
        //     --mpw.key=
        System.out.println("启动参数加上这个：--mpw.key=");
        System.out.println("生成的16位随机AES密钥 ："+randomKey);

        //要加密的数据
        String user = "zhangwu";
        String pass = "xjlsj";
        String url = "jdbc:p6spy:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone = Asia/Shanghai";
        // 随机密钥加密
        String result = AES.encrypt(url, randomKey);
        String result1 = AES.encrypt(user, randomKey);
        String result2 = AES.encrypt(pass, randomKey);
        System.out.println("加密后的url："+result);
        System.out.println("加密后的username："+result1);
        System.out.println("加密后的password："+result2);
        System.out.println();
        System.out.println("-------------------以下直接复制粘贴--------------------");
        System.out.println();
        System.out.println("============ 启动参数 ============");
        System.out.println("--mpw.key="+randomKey);
        System.out.println("============ url ============");
        System.out.println("mpw:"+result);
        System.out.println("============ username ============");
        System.out.println("mpw:"+result1);
        System.out.println("============ password ============");
        System.out.println("mpw:"+result2);
        //application配置的时候
        //mpw: 后跟加密后的数据，不需要空格

    }
}
